<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="<%=request.getContextPath()%>/image/LOGO.png" type="image/x-icon" />
<title>打印登记查询</title>
</head>
<body>
    <div class="easyui-panel" data-options="fit:true,border:0">
		<div id="PrintQueryBar" class="paddingTBL">
		    <div class="paddingB">
		   		<label class="labelWid3">姓&nbsp;名&nbsp;</label>
				<input type="text" class="easyui-textbox" id="PrintQuery_Name" data-options="width:120,height:24"/>
			    <label class="paddingL">出院日期&nbsp;</label>
				<input type="text" class="easyui-datebox" id="PrintQuery_Date1" data-options="width:115,height:24"/>
				<label>&nbsp;至&nbsp;</label>
				<input type="text" class="easyui-datebox" id="PrintQuery_Date2" data-options="width:115,height:24"/>
		    	<label class="paddingL">出院科室&nbsp;</label>
				<input type="text" class="" id="PrintQuery_Dept" data-options="width:120,height:24"/>
			</div>
			<div>
		    	<label>病案号&nbsp;</label>
				<input type="text" class="easyui-textbox" id="PrintQuery_Fprn" data-options="width:120,height:24"/>
				<label class="labelWid4 paddingL">条码号&nbsp;</label>
				<input type="text" class="easyui-textbox" id="PrintQuery_Barcode" data-options="width:120,height:24"/>
				<label class="paddingL">次数&nbsp;</label>
				<input type="text" class="easyui-numberbox" id="PrintQuery_Ftimes" data-options="width:80,height:24"/>
				<label class="paddingL">性别&nbsp;</label>
				<select class="easyui-combobox" id="PrintQuery_Sex" data-options="width:60,height:'auto'">
					<option value="0" selected="selected">全部</option>
		            <option value="1" >男</option>
		            <option value="2">女</option>
				</select>
				<span class="paddingL"></span>
				<a href="#" class="easyui-linkbutton" onclick="PrintQuery()">检 索</a>
			</div>
		</div>
		<table id="PrintQueryGrid"></table>
  </div>
  
  <%-- <script type="text/javascript" src="<%=request.getContextPath()%>/js/Print/PrintQuery.js"></script> --%>
  <script type="text/javascript">
  
  	$(function(){
  		//获取出院科室
  		$("#PrintQuery_Dept").combobox({
  			url:ctx + "/Print/getDept",
  			valueField:"ftykh",
  			textField:"fksname",
  			width:120, 
  			height:24,
  			onLoadSuccess : function() {
  				$('#PrintQuery_Dept').combobox('select', 'TZYQY');
  			}
  		});
  		
  		//加载数据表格
  		$("#PrintQueryGrid").datagrid({
  			url:'',
  			toolbar:"#PrintQueryBar",
  			fitColumns:true,
  			border : false,
  			striped : true,
  			fit : true,
  			singleSelect: true,
  			pagination : true,
  			pageSize : 20,
  			pageList : [ 20, 30,50 ],
  			columns:[[
  	            {field:'operat',title:'操作',width:60,align:'center',
  	            	formatter:function(value,row,index){
  	            		return "<button class='shootBtn' onclick='openRegister("+index+")'>打印</button>";
  	            	}
  	            },  
  				{field:'fprn',title:'病案号',width:130,align:'center'},  
  				{field:'fzyid',title:'住院ID',width:130,align:'center'},  
  				{field:'ftimes',title:'次数',width:60,align:'center' },  
  				{field:'fname',title:'姓名',width:90,align:'center' },  
  				{field:'fsex',title:'性别',width:60,align:'center' },  
  				{field:'fbirthday',title:'出生日期',width:130,align:'center',
  					formatter:function(value){
  						return new Date(value).format("yyyy-MM-dd");
  					}
  				},  
  				{field:'fbarcode',title:'条码号',width:180,align:'center' },  
  				{field:'fcydate',title:'出院日期',width:130,align:'center',
  					formatter:function(value){
  						return new Date(value).format("yyyy-MM-dd");
  					}
  				},  
  				{field:'frydept',title:'入院科室',width:130,align:'center' },  
  				{field:'fcydept',title:'出院科室',width:130,align:'center' },  
  				{field:'frydate',title:'入院日期',width:130,align:'center',
  					formatter:function(value){
  						return new Date(value).format("yyyy-MM-dd");
  					}	
  				} ,
  				{field:'fcybs',title:'出院病室',width:130,align:'center',hidden:true },  
  				{field:'fidcard',title:'身份证',width:130,align:'center',hidden:true }  
  			       ]]
  		});
  	});
  
  //查询
  	function PrintQuery(){
  		var date1 = $("#PrintQuery_Date1").datebox("getValue");
  		var date2 = $("#PrintQuery_Date2").datebox("getValue");
  		var fcydept = $("#PrintQuery_Dept").combobox("getValue");
  		var fname = $("#PrintQuery_Name").textbox("getValue");
  		var fprn = $("#PrintQuery_Fprn").textbox("getValue");
  		var fbarcode = $("#PrintQuery_Barcode").textbox("getValue");
  		var ftimes = $("#PrintQuery_Ftimes").numberbox("getValue");
  		var fsex = $("#PrintQuery_Sex").combobox("getValue");
  		$("#PrintQueryGrid").datagrid({
  			url:ctx + "/Print/printDataQuery",
  			queryParams:{
  				"date1" : date1,
  				"date2" : date2,
  				"fcydept" : fcydept,
  				"fprn" : fprn,
  				"ftimes" : ftimes,
  				"fbarcode" : fbarcode,
  				"fname" : fname,
  				"fsex" : fsex,
  			}
  		});
  	}

  	//打开打印登记页面
  	function openRegister(index){
  		var rows = $("#PrintQueryGrid").datagrid("getRows")[index];
  		var fcydate = new Date(rows.fcydate).format("yyyy-MM-dd");
  		var frydate = new Date(rows.frydate).format("yyyy-MM-dd");
  		var url = ctx + "/Print/PrintRegister?fprn="+rows.fprn+"&fzyid="+rows.fzyid+"&fcydate="+fcydate+"&frydate="+frydate+
  					"&fcydept="+encodeURI(encodeURI(rows.fcydept))+"&fcybs="+encodeURI(encodeURI(rows.fcybs))+"&fname="+encodeURI(encodeURI(rows.fname))+"&fidcard="+rows.fidcard
  					+"&ftimes="+rows.ftimes+"&fsex="+encodeURI(encodeURI(rows.fsex));
  		addTab("打印登记", url,"", false);
  		/* var tabPanel = $('#tabs');
  		tabPanel.tabs('close',"打印登记查询"); */
  	}
  </script>
</body>
</html>